package com.cheese.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class PriceController {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @ResponseBody
    @GetMapping("/hello1")
    public List<String> map(){
        String fund_code = "000001a";
        String sql = "select `累计净值` from " + fund_code + " order by id DESC";
        List<Map<String,Object>> list =  jdbcTemplate.queryForList(sql);
        List<String> prices = new ArrayList<String>();
        for(int i = 0;i < list.size();i++){
            String price = list.get(i).get("累计净值").toString();
            prices.add(price);
        }

        return prices;
    }
}